import Attacking
import Fleeing
import Wandering

# **
# *  'SM_Pirate' handles influence imposed by the World through
# *  its Owner (self.ship) and responds accordingly, usually instigating 
# *  state transitions through influence parameters, specified in the Legend (Below).
# *  
# *
# * PUBLIC FEATURES:
# *    // Constructors
# *    def __init__(self, ship)
# *
# *    // Methods
# *    def changeState(self,state)
# *    def handleMessage(self, msg, telegram)
# *    def revertToPreviousState(self)
# *    def update(self, msg, time):
# *
# *    COLLABORATORS:
# *    Fleeing
# *    Attacking
# *    Wandering
# *
# * MODIFIED:
# * @version 1.1, 2007-05-24
# * @author Julian Andreou 5422329
# * @author Gavan Hunter 5422264
# * @author  Simon Iskra 5422361
# * @author  Joel Schmidt 2660660 
# */

#**Influence Legend
#
#    0:    Fleeing     *Change State*
#    1:    Attacking   *Change State*
#    2:    Wandering   *Change State*




class SM_Pirate():
    def __init__(self, ship): 
        self.currentState = Wandering.Wandering()
        self.previousState = Wandering.Wandering()
        self.ship = ship
    
    def changeState(self, state):
        self.previousState = self.currentState
    
        self.currentState.Exit(self.ship)
        
        self.currentState = state
        
        self.currentState.Enter(self.ship)
    
    def handleInfluence(self, influence):        
        
        
        self.ship.getAllertRadius()
        
        x = 0
        
        for i in influenceArea:
            for j in influenceArea[i]:
                x+=1
                
                if influenceArea[i][j] == self.ship:
                    pass      

        if telegram.msg == 0:
            self.changeState(Fleeing.Fleeing())
            
        if telegram.msg == 1:
            self.changeState(Depositing.Depositing())
         
        if telegram.msg == 2:
            self.changeState(Mining.Mining())
            
        if telegram.msg == 3:
            self.revertToPreviousState()
        
        self.currentHS.OnMessage(self.ship, telegram)

    def revertToPreviousState(self):
        self.changeState(self.previousState)

    def update(self, msg, time):
        self.currentState.Execute(self.ship, msg)

        